#ifndef BANK_ACCOUNT_HH
#define BANK_ACCOUNT_HH

#include <string>
#include <vector>
#include <map>
#include "Transaction.hh"

// 货币类型枚举
enum class Currency {
    CNY, // 人民币
    USD, // 美元
    EUR  // 欧元/法郎
};

// 货币转换工具类
class CurrencyConverter {
public:
    // 获取当前汇率 (基准币种为CNY)
    static double getExchangeRate(Currency from, Currency to);
    
    // 根据1%手续费计算实际兑换金额
    static double calculateExchangeAmount(double amount, Currency from, Currency to);
    
    // 获取货币符号
    static std::string getCurrencySymbol(Currency currency);
    
    // 获取货币名称
    static std::string getCurrencyName(Currency currency);
};

class Account {
protected:
    std::string accountId;
    std::string ownerName; // For linking back to customer, might need a Customer pointer/ID
    
    // 各种货币的余额
    std::map<Currency, double> balances;
    Currency primaryCurrency; // 主要货币类型（默认为CNY）
    
    std::vector<Transaction> transactionHistory;

public:
    Account(std::string id, std::string owner, double initialBalance = 0.0);
    virtual ~Account() = default; // Virtual destructor for base class

    std::string getAccountId() const;
    std::string getOwnerName() const;
    
    // 获取指定货币的余额
    double getBalance(Currency currency = Currency::CNY) const;
    
    // 获取主要货币的余额（向后兼容）
    double getBalance() const;
    
    // 获取所有货币的余额
    const std::map<Currency, double>& getAllBalances() const;
    
    // 设置主要货币类型
    void setPrimaryCurrency(Currency currency);
    
    // 获取主要货币类型
    Currency getPrimaryCurrency() const;
    
    const std::vector<Transaction>& getTransactionHistory() const;

    virtual void displayDetails() const = 0; // Pure virtual function for account type display
    virtual bool canDeposit() const = 0;
    virtual bool canWithdraw() const = 0;
    virtual bool canTransferTo(const Account& destinationAccount) const = 0;

    void addTransaction(const Transaction& transaction);

    // 新增支持多货币的方法
    virtual bool deposit(double amount, Currency currency, const std::string& note);
    virtual bool withdraw(double amount, Currency currency, const std::string& note);
    
    // 货币兑换方法
    bool exchangeCurrency(Currency from, Currency to, double amount, const std::string& note);
    
    // 保留原有方法(默认使用CNY)
    virtual bool deposit(double amount, const std::string& note);
    virtual bool withdraw(double amount, const std::string& note);
    virtual bool transfer(Account& destinationAccount, double amount, const std::string& note);
    
    // 支持指定货币的转账
    virtual bool transfer(Account& destinationAccount, double amount, Currency currency, const std::string& note);
    
    // 获取账户类型名称
    virtual std::string getAccountTypeName() const = 0;
};

#endif // BANK_ACCOUNT_HH 